'use strict';
//库
import React, { StyleSheet,View,DrawerLayoutAndroid} from 'react-native';
//组件
import Topbar from '../components/mainScreen/topbar';
import FarmList from '../components/mainScreen/farmlist';
import BwList from '../components/mainScreen/bwlist';
import DrawerView from '../components/drawer/drawerview'


class mainScreen extends React.Component {
	openDrawer= ()=> {
		this.refs['DRAWER'].openDrawer()
	};
  	render() {
	  	//没有drawer的主页面
	  	var mainscreen=(
	  		<View style={styles.contain}>
	          <View style={styles.topbar}>
	            <Topbar 
	              	openDrawer={this.openDrawer}>
	            </Topbar>
	          </View>
	          <View style={styles.farmlistAndbwlist}>
	            <View style={styles.bwlist}>
	              	<BwList 
		                navigator={this.props.navigator}
		                //reduxChangeFarmunit={this.props.mapactions.reduxChangeFarmunit}
		                //reduxEnterFarmunit={this.props.mapactions.reduxEnterUnit}
	              	>
	              	</BwList>
	            </View>
	            {/*右侧猪场列表*/}
	            <View style={styles.farmlist}>
	              <FarmList></FarmList>
	            </View>
	          </View>
	        </View>
	  	);
	  	//抽屉
	  	var navigationView = (
	    	<View style={{flex: 1, backgroundColor: '#fff'}}>
	        	<DrawerView></DrawerView>
	      	</View>
	    );
	    return (
			<DrawerLayoutAndroid
	          	//打开时的抽屉宽度
	        	drawerWidth={280}
	          	ref={'DRAWER'}
	          	//左边弹出
	          	drawerPosition={DrawerLayoutAndroid.positions.Left}
	          	//弹出的页面
	          	renderNavigationView={() => navigationView}>
	            {/*不显示抽屉时的页面*/}
	            <View style={{flex: 1,alignSelf:'stretch'}}>
	              {mainscreen}
	            </View>
	      	</DrawerLayoutAndroid>
	    );
  	}
}

const styles = StyleSheet.create({
	contain:{
	  	flex:1,
	  	//backgroundColor:"red"
	},
	topbar:{
	  	flex:1,
	  	//backgroundColor:"green"
	},
	farmlistAndbwlist:{
	  	flex:10,
	  	//backgroundColor:"yellow",
	  	flexDirection:"row"
	},
	farmlist:{
	  	flex:3,
	    borderStyle: null,
	    borderRightColor:'grey',
	    borderLeftWidth:0.5
	  	//backgroundColor:"blue"
	},
	bwlist:{
	  	flex:10,
		backgroundColor:"#CFE2EB"
	}
});


export default mainScreen;